package com.zushiye.order.mapper;

import com.zushiye.order.model.OrderItemBean;
import com.zushiye.order.model.request.OrderUpdateRequest;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface OrderMapper {

    @Insert("insert into my_order(user_id, state, order_code, total_price, score, goods_ids, shop_name," +
            " img_id, date_added, timestamp) " +
            "values(#{user_id}, #{state}, #{order_code}, #{total_price}, #{score}, #{goods_ids}, #{shop_name}," +
            " #{img_id}, #{date_added}, #{timestamp}" +
            ")")
    int insert(OrderItemBean itemBean);

    @Delete("delete from my_order where id = #{id}")
    int delete(String id);

    @Select("select * from my_order where user_id = #{user_id}")
    List<OrderItemBean> queryAll(String user_id);

    @Update("UPDATE my_order SET state=${state} WHERE id=${id}")
    int updateState(OrderUpdateRequest req);

    @Update("update my_order set state=#{state}, order_code=#{order_code}, total_price=#{total_price}, " +
            "score=#{score}, goods_ids=#{goods_ids}, shop_name=#{shop_name}, img_id=#{img_id}, " +
            "date_added=#{date_added}, date_added=#{timestamp}" +
            " where id=#{id}")
    int update(String id);

}
